package com.zhengsr.drawbroad;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.zhengsr.drawbroad.state.EraserState;
import com.zhengsr.drawbroad.state.PenState;

public class MainActivity extends AppCompatActivity {
    private BaseDrawView mDrawView;
    private ImageView mPenImageView,mEraserImageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        mDrawView = (BaseDrawView) findViewById(R.id.broadview);
        mDrawView.setCurrentState(new PenState());
        mPenImageView = (ImageView) findViewById(R.id.pen);
        mEraserImageView = (ImageView) findViewById(R.id.eraser);
        mPenImageView.setSelected(true);
    }

    public void clear(View view) {
        mDrawView.reset();
    }

    public void redo(View view) {
        mDrawView.redo();
    }

    public void undo(View view) {
        mDrawView.undo();
    }

    public void eraser(View view) {
        mDrawView.setCurrentState(new EraserState());
        mEraserImageView.setSelected(true);
        mPenImageView.setSelected(false);
    }

    public void paint(View view) {
        mDrawView.setCurrentState(new PenState());
        mEraserImageView.setSelected(false);
        mPenImageView.setSelected(true);
    }

    public void multcolor(View view) {
        mDrawView.setPaintColor(Color.GREEN);
    }
}
